<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>案例绘编类型管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="/frontEnd/images/favicon.ico">
    <link rel="stylesheet" href="/layuicms/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/layuicms/css/public.css" media="all" />
    <link rel="stylesheet" href="/kindeditor/themes/default/default.css" />
    <link rel="stylesheet" href="/kindeditor/plugins/code/prettify.css" />
    <script charset="utf-8" src="/kindeditor/kindeditor-all.js"></script>
    <script charset="utf-8" src="/kindeditor/lang/zh-CN.js"></script>
    <script charset="utf-8" src="/layuicms/js/x-layui.js"></script>
    <script type="text/javascript" src="/layuicms/layui/layui.js"></script>
    <style type="text/css">
        .ke-container.ke-container-default{
            width: 100% !important;
        }
    </style>
</head>

<body>
<!-- 添加和修改的弹出层开始 -->
<div style="padding: 5px 20px 0 0" id="addOrUpdateDiv">
    <form action="" method="post" class="layui-form" id="dataFrm" lay-filter="dataFrm">
        <div class="layui-form-item">
                <label class="layui-form-label">警示类型</label>
                <div class="layui-input-block">
                    <select name="safetyId" id="safetyId" lay-verify="required"  class="search_safety">
                        <option value="">请选择警示类型</option>
                    </select>
                </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">案例标题</label>
            <div class="layui-input-block">
                <input type="hidden" name="id">
                <input type="text" name="caseTitle" lay-verify="required" lay-reqtext="案例标题是必填项，岂能为空？" placeholder="请输入" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">案例详情</label>
            <div class="layui-input-block">
                <!-- 加载编辑器的容器 -->
                <textarea name="caseInfo" id="caseInfo" cols="100" rows="8" style="width:800px; height:300px;visibility:hidden;"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">是否可用</label>
                <div class="layui-input-inline">
                    <input type="radio" name="available" value="1" title="可用" checked="">
                    <input type="radio" name="available" value="0" title="不可用" >
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">排序码</label>
                <div class="layui-input-block">
                    <input type="text" id="ordernum" name="ordernum" lay-verify="required|number" autocomplete="off" placeholder="请输入排序码[>0]" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block" style="text-align: center;">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="doSubmit" id="doSubmit" ><span class="layui-icon layui-icon-add-1"></span>提交</button>
                <button type="reset" class="layui-btn layui-btn-warm"><span class="layui-icon layui-icon-refresh-1"></span>重置</button>
            </div>
        </div>
    </form>
</div>
<!-- 添加和修改的弹出层结束 -->
</body>
<script type="text/javascript" src="/layuicms/layui/layui.js"></script>
<script type="text/javascript">
        layui.use(['jquery','form','table','layer'],function(){
            var $ = layui.jquery;
            var form=layui.form;
            var layer = layui.layer;
            function getKindeditor(){
                editor = KindEditor.create('textarea[name="caseInfo"]', {
                    allowFileManager : true,
                    allowImageUpload:true,//允许上传图片
                    allowFileManager:true, //允许对上传图片进行管理
                    uploadJson:"/uploadImg",
                    afterUpload: function(){this.sync();}, //图片上传后，将上传内容同步到textarea中
                    afterBlur: function(){this.sync();},   //失去焦点时，将上传内容同步到textarea中
                    items : [
                        'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
                        'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                        'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                        'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
                        'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                        'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image',
                        'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
                        'anchor', 'link', 'unlink', '|', 'about'
                    ]
                });
                return editor;
            }
            getKindeditor();
             $.get("/caseManagement/loadCaseMaxOrderNum",function (res) {
                 $("#ordernum").val(res.value);
             });
            //模糊查询
            //加载查询条件供应商的下拉列表
            $.get("/safetyAlertType/loadAllsafetyAlertTypeForSelect",function(res){
                var data=res.data;
                var dom=$(".search_safety");
                var html='<option value="">请选择警示类型</option>'
                $.each(data,function(index,item){
                    html+='<option value="'+item.id+'">'+item.typename+'</option>'
                });
                dom.html(html);
                form.render("select");
            });
            //添加和修改的提交
            form.on("submit(doSubmit)",function (data) {
                $.post("/caseManagement/addCaseManagement",data.field,function (res) {
                    if(res.code==20000){
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        parent.location.reload();
                    }
                    layer.msg(res.message);
                    parent.layer.close(index);
                })
                return false
            });
        });
</script>
</html>